//本文件由程序自动生成,请不要自行修改
using System;
using fastCSharp;

#if NotFastCSharpCode
#else
#pragma warning disable
namespace diantou.dataAccess.tcpClient
{
        public partial class onlineJudgeData
        {

            /// <summary>
            /// OJData TCP服务参数
            /// </summary>
            public sealed class tcpServer
            {

                [fastCSharp.emit.dataSerialize(IsMemberMap = false)]
                internal struct _i0
                {
                    public int problemId;
                }
                [fastCSharp.emit.dataSerialize(IsMemberMap = false)]
                [fastCSharp.emit.boxSerialize]
                internal struct _o0 : fastCSharp.net.asynchronousMethod.IReturnParameter<OnlineJudge.problemData>
                {
                    [fastCSharp.emit.jsonSerialize.member(IsIgnoreCurrent = true)]
                    [fastCSharp.emit.jsonParse.member(IsIgnoreCurrent = true)]
                    public OnlineJudge.problemData Ret;
                    public OnlineJudge.problemData Return
                    {
                        get { return Ret; }
                        set { Ret = value; }
                    }
                }
                [fastCSharp.emit.dataSerialize(IsMemberMap = false, IsReferenceMember = false)]
                internal struct _i1
                {
                    public ulong randomPrefix;
                    public byte[] md5Data;
                    public long ticks;
                }
                [fastCSharp.emit.dataSerialize(IsMemberMap = false, IsReferenceMember = false)]
                [fastCSharp.emit.boxSerialize]
                internal struct _o1 : fastCSharp.net.asynchronousMethod.IReturnParameter<bool>
                {
                    public long ticks;
                    [fastCSharp.emit.jsonSerialize.member(IsIgnoreCurrent = true)]
                    [fastCSharp.emit.jsonParse.member(IsIgnoreCurrent = true)]
                    public bool Ret;
                    public bool Return
                    {
                        get { return Ret; }
                        set { Ret = value; }
                    }
                }
                [fastCSharp.emit.dataSerialize(IsMemberMap = false)]
                [fastCSharp.emit.boxSerialize]
                internal struct _o2 : fastCSharp.net.asynchronousMethod.IReturnParameter<fastCSharp.keyValue<int,System.DateTime>[]>
                {
                    [fastCSharp.emit.jsonSerialize.member(IsIgnoreCurrent = true)]
                    [fastCSharp.emit.jsonParse.member(IsIgnoreCurrent = true)]
                    public fastCSharp.keyValue<int,System.DateTime>[] Ret;
                    public fastCSharp.keyValue<int,System.DateTime>[] Return
                    {
                        get { return Ret; }
                        set { Ret = value; }
                    }
                }
            }

            /// <summary>
            /// TCP客户端
            /// </summary>
            public class tcpClient : fastCSharp.net.tcp.timeVerifyServer.ITimeVerifyClient, fastCSharp.net.tcp.commandClient.IClient
            {
                /// <summary>
                /// 时间验证服务客户端验证函数
                /// </summary>
                public sealed class timeVerifyMethod : fastCSharp.code.cSharp.tcpBase.ITcpClientVerifyMethod<tcpClient>
                {
                    /// <summary>
                    /// 时间验证服务客户端验证函数
                    /// </summary>
                    /// <param name="client">TCP调用客户端</param>
                    /// <returns>是否通过验证</returns>
                    public bool Verify(tcpClient client)
                    {
                        return fastCSharp.net.tcp.timeVerifyServer.Verify(client);
                    }
                }
                /// <summary>
                /// TCP调用客户端
                /// </summary>
                private fastCSharp.net.tcp.commandClient tcpCommandClient;
                /// <summary>
                /// TCP调用客户端
                /// </summary>
                public fastCSharp.net.tcp.commandClient TcpCommandClient { get { return tcpCommandClient; } }
                /// <summary>
                /// TCP调用客户端
                /// </summary>
                /// <param name="attribute">TCP调用服务器端配置信息</param>
                /// <param name="verifyMethod">TCP验证方法</param>
                public tcpClient(fastCSharp.code.cSharp.tcpServer attribute = null, fastCSharp.code.cSharp.tcpBase.ITcpClientVerifyMethod<tcpClient> verifyMethod = null)
                {
                    tcpCommandClient = new fastCSharp.net.tcp.commandClient<tcpClient>(attribute ?? fastCSharp.code.cSharp.tcpServer.GetConfig(TcpServerAttribute, "OJData"), 28, verifyMethod ?? new diantou.dataAccess.tcpClient.onlineJudgeData.tcpClient.timeVerifyMethod(), this);
                }
                /// <summary>
                /// 释放资源
                /// </summary>
                public void Dispose()
                {
                    fastCSharp.pub.Dispose(ref tcpCommandClient);
                }

                /// <summary>
                /// TCP服务调用配置
                /// </summary>
                public static fastCSharp.code.cSharp.tcpServer TcpServerAttribute
                {
                    get { return fastCSharp.emit.jsonParser.Parse<fastCSharp.code.cSharp.tcpServer>(@"{""AcceptQueueCount"":0,""AcceptThreadPriority"":""Normal"",""ClientCheckSeconds"":50,""ClientSegmentationCopyPath"":""C:\\diantou\\OnlineJudgeClient\\"",""ClientSendSleep"":1,""Filter"":""NonPublicInstance"",""Host"":null,""HttpEncodingName"":null,""IsAttribute"":true,""IsBaseTypeAttribute"":false,""IsClientAsynchronousReceive"":false,""IsClientInterface"":false,""IsCompress"":true,""IsFixedClientHost"":false,""IsHttpClient"":false,""IsIdentityCommand"":true,""IsIgnoreCurrent"":false,""IsInheritAttribute"":true,""IsJsonSerialize"":false,""IsLoadBalancing"":false,""IsMarkData"":true,""IsPerpleRegister"":true,""IsRegisterCheckHost"":true,""IsRememberIdentityCommand"":true,""IsSegmentation"":true,""IsServer"":false,""IsServerAsynchronousReceive"":false,""IsSingleRegister"":true,""IsTryJsonSerializable"":false,""LoadBalancingCheckSeconds"":0,""LoadBalancingRouterRetrySeconds"":0,""LoadBalancingTryCount"":3,""MaxActiveClientCountIpAddress"":0,""MaxClientCount"":0x7FFFFFFF,""MaxClientCountPerIpAddress"":0,""MaxClientSendCount"":1024,""MaxServerSendCount"":1024,""MinReceivePerSecond"":0,""Port"":0,""ReceiveBufferSize"":4096,""ReceiveTimeout"":0,""RecieveCommandMinutes"":0,""RegisterHost"":null,""RegisterPort"":0,""SendBufferSize"":4096,""ServerSendSleep"":1,""Service"":""OJData"",""TcpRegister"":null,""VerifySeconds"":20,""VerifyString"":null,""IsHttpClientOrJsonSerialize"":false,""IsSetup"":true,""MemberFilter"":""NonPublicInstance"",""ServiceName"":""OJData"",""TcpRegisterName"":null,""TypeId"":{}}"); }
                }

                /// <summary>
                /// 忽略TCP分组
                /// </summary>
                /// <param name="groupId">分组标识</param>
                /// <returns>是否调用成功</returns>
                public fastCSharp.net.returnValue.type TcpIgnoreGroup(int groupId)
                {
                    fastCSharp.net.tcp.commandClient client = TcpCommandClient;
                    return client == null ? fastCSharp.net.returnValue.type.ClientDisposed : client.IgnoreGroup(groupId);
                }

                private static readonly fastCSharp.net.tcp.commandClient.identityCommand _c0 = new fastCSharp.net.tcp.commandClient.identityCommand { Command = 0 + 128, MaxInputSize = 2147483647, IsKeepCallback = 0, IsSendOnly = 0 };

                /// <summary>
                /// 获取题目数据
                /// </summary>
                public fastCSharp.net.returnValue<OnlineJudge.problemData> getData(int problemId)
                {
                    fastCSharp.net.returnValue.type _returnType_;
                    fastCSharp.net.waitCall<tcpServer._o0> _wait_ = fastCSharp.net.waitCall<tcpServer._o0>.Get();
                    if (_wait_ == null) _returnType_ = fastCSharp.net.returnValue.type.ClientException;
                    else
                    {
                        
                        getData(problemId, null, _wait_, false);
                        fastCSharp.net.returnValue<tcpServer._o0> _outputParameter_ = _wait_.Value;
                        if (_outputParameter_.Type == fastCSharp.net.returnValue.type.Success)
                        {
                            return _outputParameter_.Value.Return;
                        }
                        _returnType_ = _outputParameter_.Type;
                    }
                    return new fastCSharp.net.returnValue<OnlineJudge.problemData>{ Type = _returnType_ };
                }


                private void getData(int problemId, Action<fastCSharp.net.returnValue<tcpServer._o0>> _onReturn_, fastCSharp.net.callback<fastCSharp.net.returnValue<tcpServer._o0>> _callback_, bool _isTask_)
                {
                    fastCSharp.net.returnValue.type _returnType_;
                    try
                    {
                        fastCSharp.net.tcp.commandClient.streamCommandSocket _socket_ = TcpCommandClient.StreamSocket;
                        if (_socket_ != null)
                        {
                            tcpServer._i0 _inputParameter_ = new tcpServer._i0
                            {
                                problemId = problemId,
                            };
                            tcpServer._o0 _outputParameter_ = new tcpServer._o0();
                            _socket_.Get(_onReturn_, _callback_, _c0, ref _inputParameter_, _outputParameter_, _isTask_);
                            return;
                        }
                        _returnType_ = fastCSharp.net.returnValue.type.ClientDisposed;
                    }
                    catch (Exception _error_)
                    {
                        _returnType_ = fastCSharp.net.returnValue.type.ClientException;
                        fastCSharp.log.Error.Add(_error_, null, false);
                    }
                    if (_callback_ != null) _callback_.Callback(new fastCSharp.net.returnValue<tcpServer._o0>{ Type = _returnType_ });
                    else if (_onReturn_ != null) _onReturn_(new fastCSharp.net.returnValue<tcpServer._o0>{ Type = _returnType_ });
                }
                private static readonly fastCSharp.net.tcp.commandClient.identityCommand _c1 = new fastCSharp.net.tcp.commandClient.identityCommand { Command = 1 + 128, MaxInputSize = 1024, IsKeepCallback = 0, IsSendOnly = 0 };

                /// <summary>
                /// 时间验证函数
                /// </summary>
                /// <returns>是否验证成功</returns>
                public fastCSharp.net.returnValue<bool> verify(ulong randomPrefix, byte[] md5Data, ref long ticks)
                {
                    fastCSharp.net.returnValue.type _returnType_;
                    fastCSharp.net.waitCall<tcpServer._o1> _wait_ = fastCSharp.net.waitCall<tcpServer._o1>.Get();
                    if (_wait_ == null) _returnType_ = fastCSharp.net.returnValue.type.ClientException;
                    else
                    {
                        
                        verify(randomPrefix, md5Data, ref ticks, null, _wait_, false);
                        fastCSharp.net.returnValue<tcpServer._o1> _outputParameter_ = _wait_.Value;
                        if (_outputParameter_.Type == fastCSharp.net.returnValue.type.Success)
                        {
                            ticks = _outputParameter_.Value.ticks;
                            return _outputParameter_.Value.Return;
                        }
                        _returnType_ = _outputParameter_.Type;
                    }
                    return new fastCSharp.net.returnValue<bool>{ Type = _returnType_ };
                }


                private void verify(ulong randomPrefix, byte[] md5Data, ref long ticks, Action<fastCSharp.net.returnValue<tcpServer._o1>> _onReturn_, fastCSharp.net.callback<fastCSharp.net.returnValue<tcpServer._o1>> _callback_, bool _isTask_)
                {
                    fastCSharp.net.returnValue.type _returnType_;
                    try
                    {
                        fastCSharp.net.tcp.commandClient.streamCommandSocket _socket_ = TcpCommandClient.VerifyStreamSocket;
                        if (_socket_ != null)
                        {
                            tcpServer._i1 _inputParameter_ = new tcpServer._i1
                            {
                                randomPrefix = randomPrefix,
                                md5Data = md5Data,
                                ticks = ticks,
                            };
                            tcpServer._o1 _outputParameter_ = new tcpServer._o1();
                            _outputParameter_.ticks = _inputParameter_.ticks;
                            _socket_.Get(_onReturn_, _callback_, _c1, ref _inputParameter_, _outputParameter_, _isTask_);
                            return;
                        }
                        _returnType_ = fastCSharp.net.returnValue.type.ClientDisposed;
                    }
                    catch (Exception _error_)
                    {
                        _returnType_ = fastCSharp.net.returnValue.type.ClientException;
                        fastCSharp.log.Error.Add(_error_, null, false);
                    }
                    if (_callback_ != null) _callback_.Callback(new fastCSharp.net.returnValue<tcpServer._o1>{ Type = _returnType_ });
                    else if (_onReturn_ != null) _onReturn_(new fastCSharp.net.returnValue<tcpServer._o1>{ Type = _returnType_ });
                }
                private static readonly fastCSharp.net.tcp.commandClient.identityCommand _c2 = new fastCSharp.net.tcp.commandClient.identityCommand { Command = 2 + 128, MaxInputSize = 0, IsKeepCallback = 0, IsSendOnly = 0 };


                /// <summary>
                /// 获取题目最后更新时间
                /// </summary>
                public fastCSharp.net.returnValue<fastCSharp.keyValue<int,System.DateTime>[]> problemTimes
                {
                    get
                    {
                    fastCSharp.net.returnValue.type _returnType_;
                    fastCSharp.net.waitCall<tcpServer._o2> _wait_ = fastCSharp.net.waitCall<tcpServer._o2>.Get();
                    if (_wait_ == null) _returnType_ = fastCSharp.net.returnValue.type.ClientException;
                    else
                    {
                        
                        get_problemTimes(null, _wait_, false);
                        fastCSharp.net.returnValue<tcpServer._o2> _outputParameter_ = _wait_.Value;
                        if (_outputParameter_.Type == fastCSharp.net.returnValue.type.Success)
                        {
                            return _outputParameter_.Value.Return;
                        }
                        _returnType_ = _outputParameter_.Type;
                    }
                        return new fastCSharp.net.returnValue<fastCSharp.keyValue<int,System.DateTime>[]> { Type = _returnType_ };
                    }
                }

                private void get_problemTimes(Action<fastCSharp.net.returnValue<tcpServer._o2>> _onReturn_, fastCSharp.net.callback<fastCSharp.net.returnValue<tcpServer._o2>> _callback_, bool _isTask_)
                {
                    fastCSharp.net.returnValue.type _returnType_;
                    try
                    {
                        fastCSharp.net.tcp.commandClient.streamCommandSocket _socket_ = TcpCommandClient.StreamSocket;
                        if (_socket_ != null)
                        {
                            tcpServer._o2 _outputParameter_ = new tcpServer._o2();
                            _socket_.Get(_onReturn_, _callback_, _c2, _outputParameter_, _isTask_);
                            return;
                        }
                        _returnType_ = fastCSharp.net.returnValue.type.ClientDisposed;
                    }
                    catch (Exception _error_)
                    {
                        _returnType_ = fastCSharp.net.returnValue.type.ClientException;
                        fastCSharp.log.Error.Add(_error_, null, false);
                    }
                    if (_callback_ != null) _callback_.Callback(new fastCSharp.net.returnValue<tcpServer._o2>{ Type = _returnType_ });
                    else if (_onReturn_ != null) _onReturn_(new fastCSharp.net.returnValue<tcpServer._o2>{ Type = _returnType_ });
                }
            }

        }
}
#endif